package com.erp.Util;

import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class WebUtil {
    //获取request
    public static HttpServletRequest getRequest(){
            HttpServletRequest request =null;
        //上下文
        ServletRequestAttributes sra=
                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        request =sra.getRequest();
            return  request;


    }


    //获取Session
    public static HttpSession getSession(){
        HttpSession session = getRequest().getSession();
        return session;

    }
}
